<%--
 *  File:    DeptSummary.jsp
 *  @Author: Hilldao 
 *  Date:    2001/11/4
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.DeptSummary"); 
%>

<%
  //init param
  String strModuleName = "OGM";
  String privilegeCode = "10102,L101";
%>



<%

  String strTableName = "ovdepartment";
  //get userinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>DeptSummary</title>
<PageFlow:CheckPageFlow pageName="deptsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<script language="JavaScript" src="../../js/opal2/mootools.js"></script>
<script language="JavaScript" src="../../js/opal2/opal2.js"></script>
<script language="JavaScript" src="../../js/opal2/DBGrid.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
  cat.debug("The strCurSearchName is :" + strCurSearchName);
  cat.debug("The strCurSearchValue is :" + strCurSearchValue);  
  cat.debug("The strCurOrderByCol is :" + strCurOrderByCol);
  cat.debug("The strCurOrderByType is :" + strCurOrderByType);
  cat.debug("The nCurMaxItem is :" + nCurMaxItem);  
  cat.debug("The nCurCount is :" + nCurCount);  
  cat.debug("The nCurPageNo is :" + nCurPageNo);
  cat.debug("The nCurTotalPage is :" + nCurTotalPage);
  cat.debug("The nCurEndIndex is :" + nCurEndIndex);
  cat.debug("The bCurHasPre is :" + bCurHasPre);
  cat.debug("The bCurHasNext is :" + bCurHasNext);     
  cat.debug("The CurUserInfo is :" + CurUserInfo);       

  Vector deptSummary = (Vector)pageContext.getAttribute("deptsummary");
  
  if(deptSummary == null)
  {
    deptSummary = new Vector();
  }
  cat.debug("The deptSummary is :" + deptSummary);
  
  if(pageContext.getAttribute("orginfo") == null)
    pageContext.setAttribute("orginfo",new HashMap());
%>
<script>
var rootPath = '<%= ConstantProp.DEFAULT_ROOT_PATH %>';
var languageCode = '<%= strLanguageCode %>';
var lnumber= '<%= label.getLabelName("L_Number") + " "%>';
var lpage='<%= " " + label.getLabelName("L_Page") %>';
var ltotal= '<%= label.getLabelName("L_Total") + " "%>';
var lset= '<%= label.getLabelName("L_Setup")%>';
var lsave= '<%= label.getLabelName("L_Save")%>';
var lcancel= '<%= label.getLabelName("L_Cancel")%>';

function page_setOrg(id,name)
{
  document.deptsummaryform.orgid.value = id;
  document.deptsummaryform.orgname.value = name;
  page_summary('search');
}

parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function clickUserGroup(id,parid,Bottom)
{
  document.deptsummaryform.deptid.value = id;
  document.deptsummaryform.isBottom.value = Bottom; 
  document.deptsummaryform.parentdeptid.value = parid;
}
function page_delete()
{
  var id = document.deptsummaryform.deptid.value;
  var isBottom = document.deptsummaryform.isBottom.value;
  if(isBottom=='N')
  {
     alert("<%= message.getMessageDesc("NOT_LEAF", label.getLabelName("L_Department",false))%>");
     return;
  }
  if(id == null || id.length == 0 || id == "" || id == "-1")
    return;
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL")%>");
  if(!flag)
    return;
  document.deptsummaryform.actionname.value = "delete";
  isRunning = true;
  document.deptsummaryform.submit();
  
}
function page_edit()
{
  var uid = document.deptsummaryform.deptid.value;
  if(uid == null || uid.length == 0 || uid == "" || uid == "-1")
    return;
  parent.down.location.href = "DeptEdit.jsp?<%= OvalTools.randomURL() %>&deptid=" + uid + "&languagecode=<%= strLanguageCode %>&orgid=<oval:write name="orginfo" property="orgid"/>";
}

function create_child()
{
  var uid = document.deptsummaryform.deptid.value;
  if(uid == null || uid.length == 0 || uid == "" || uid == "-1")
    return;
  parent.down.location.href = "DeptEdit.jsp?<%= OvalTools.randomURL() %>&parentdeptid=" + uid + "&languagecode=<%= strLanguageCode %>&orgid=<oval:write name="orginfo" property="orgid"/>";
}

var dbGrid = null;
function page_summary(actionvalue,orderbyname)
{
	
	var editform = summaryPrepare(deptsummaryform,actionvalue,orderbyname);
  //editform.action = "DeptSummary.jsp?<%= OvalTools.randomURL() %>";
 //// editform.target = "_self";
  //isRunning = true;
  //editform.submit();  
  var myHTMLRequest = new Request({
		url:'../../Dispatcher?pagename=deptsummary&actionname=testajax',
		onComplete: function(responseText,responseXML) {
			var data = JSON.decode(responseText);  //获取后台生成的对象	
			dbGrid.reload(data);
		}
								
	}).send($('deptsummaryform').toQueryString());  
}
function poporg()
{
  window.open("OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=owner&languagecode=<%= strLanguageCode %>", "newwindow", "height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}

document.addEvent('domready', function (){
	dbGrid = new opal.widget.DBGrid({
				'id': 'gridtest', 
				'data': null,
				'summaryDataName': 'deptsummary',
				'indicator': {'type': 'radio', 'dataIdColumn': 'deptid'}
			});
			
			dbGrid.addColumn({'display': '部门代码', 'field': 'deptcode'});
			dbGrid.addColumn({'display': '部门名称', 'field': 'deptname'});
			dbGrid.addColumn({'display': '上级部门', 'field': 'parentdeptname'});
			dbGrid.addColumn({'display': '部门描述', 'field': 'deptdesc'});
			dbGrid.addColumn({'display': '状态', 'field': 'statusname'});
			dbGrid.display();
			
			page_summary('search');
	
});
</script>
</head>

<body>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
 <form name="deptsummaryform" method="post" action="../../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="deptsummary">
    <input type="hidden" name="actionname" value="testajax">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <oval:hidden name="orginfo" property="orgid"/>
    
  <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0">  
        <tr> 
          <%if(privilegeSet != null && privilegeSet.contains("1000000")){%>    
          <td nowrap><%= label.getLabelName("L_OwnerOrg") + label.getLabelName("L_Colon") %>               
            	<input type="text" name="orgname" value="<oval:write name="orginfo" property="orgname"/>" size="30" readonly>
              <a onclick="poporg()"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> &nbsp;
              </td>
          <td>&nbsp;&nbsp;</td>
          <%}%>
          <td>
           <table>
         <%@ include file="/inc/SummarySearch.inc" %>
           </table>
          </td>
         </tr> 
       </table>
    </td>
  </tr>
  <tr> 
    <td> 
      
      
      <div id="gridtest"></div>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
            <a onclick="parent.down.location.href='DeptEdit.jsp?<%= OvalTools.randomURL() %>&orgid=<oval:write name="orginfo" property="orgid"/>';"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
            <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
            <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
            <a onclick="create_child()"><custom:button type="1" label="L_CreatSubDept" imgsrc="CreatSubDept.gif" border="0"/></a>
          </td>
        </tr>
            
      </table>
    </td>
  </tr>
 </form>
</table>
</body>
</html>


